home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Multimedia / MPC-HC / MPC-HC_Portable.exe / MPC-HC_Portable / Shaders / LCD angle correction.hlsl < prev    next >
Text File  |  2014-10-05  |  3KB  |  68 lines

  1. /*
  2.  * (C) 2011 Jan-Willem Krans (janwillem32 <at> hotmail.com)
  3.  * (C) 2013 see Authors.txt
  4.  *
  5.  * This file is part of MPC-HC.
  6.  *
  7.  * MPC-HC is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * MPC-HC is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  *
  20.  */
  21.  
  22. // Brightness, contrast and gamma controls for RGB, linearly scaled from top to bottom.
  23. // This shader can be run as a screen space pixel shader. It requires compiling with ps_2_0,
  24. // but higher is better see http://en.wikipedia.org/wiki/Pixel_shader to look up what PS version
  25. // your video card supports.
  26. // This shader is meant to work with linear RGB input and output. Regular R'G'B' with
  27. // a video gamma encoding will have to be converted with the linear gamma shaders to work properly.
  28.  
  29. // Fractions, either decimal or not, are allowed
  30. // RedBrightness, GreenBrightness and BlueBrightness, interval [-10, 10], default 0
  31. #define RedBrightnessTop 0
  32. #define GreenBrightnessTop 0
  33. #define BlueBrightnessTop 0
  34. #define RedBrightnessBottom 0
  35. #define GreenBrightnessBottom 0
  36. #define BlueBrightnessBottom 0
  37.  
  38. // RedContrast, GreenContrast and BlueContrast, interval [0, 10], default 1
  39. #define RedContrastTop 1
  40. #define GreenContrastTop 1
  41. #define BlueContrastTop 1
  42. #define RedContrastBottom 1
  43. #define GreenContrastBottom 1
  44. #define BlueContrastBottom 1
  45.  
  46. // RedGamma, GreenGamma and BlueGamma, interval (0, 10], default 1
  47. #define RedGammaTop 0.8
  48. #define GreenGammaTop 0.8
  49. #define BlueGammaTop 0.8
  50. #define RedGammaBottom 1
  51. #define GreenGammaBottom 1
  52. #define BlueGammaBottom 1
  53.  
  54. sampler s0;
  55.  
  56. float4 main(float2 tex : TEXCOORD0) : COLOR
  57. {
  58.     float3 s1 = tex2D(s0, tex).rgb;
  59.     // original pixel
  60.     float texyi = 1.0 - tex.y;
  61.     s1 = s1 * (texyi * float3(RedContrastTop, GreenContrastTop, BlueContrastTop) + tex.y * float3(RedContrastBottom, GreenContrastBottom, BlueContrastBottom)) + texyi * float3(RedBrightnessTop, GreenBrightnessTop, BlueBrightnessTop) + tex.y * float3(RedBrightnessBottom, GreenBrightnessBottom, BlueBrightnessBottom);
  62.     // process contrast and brightness on the original pixel
  63.     // preserve the sign bits of RGB values
  64.     float3 sb = sign(s1);
  65.     return (sb*pow(abs(s1), texyi * float3(RedGammaTop, GreenGammaTop, BlueGammaTop) + tex.y * float3(RedGammaBottom, GreenGammaBottom, BlueGammaBottom))).rgbb;
  66.     // process gamma correction and output
  67. }
  68.